home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.19981211-19990422
/
000430_news@watsun.cc.columbia.edu _Sun Apr 4 12:23:11 1999.msg
< prev
next >
Wrap
Internet Message Format
|
1999-04-21
|
3KB
Return-Path: <news@watsun.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id MAA04554
for <kermit.misc@watsun.cc.columbia.edu>; Sun, 4 Apr 1999 12:23:10 -0400 (EDT)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id MAA17138
for kermit.misc@watsun.cc.columbia.edu; Sun, 4 Apr 1999 12:18:00 -0400 (EDT)
X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Subject: Re: Is it possible to script a telnet session with bash?
Date: 4 Apr 1999 16:17:54 GMT
Organization: Columbia University
Message-ID: <7e83bi$gnf$1@newsmaster.cc.columbia.edu>
To: kermit.misc@watsun.cc.columbia.edu
In article <37062a83.6682275@news.iea.com>,
Michael Langley <mlangley@owt.com> wrote:
: I am wondering if it is possible to script a telnet session with bash?
:
The best way to script a telnet session is with a telnet client that
includes a built-in scripting capability, such as C-Kermit:
http://www.columbia.edu/kermit/ckermit.html
This way you don't have to worry about interactions or misunderstandings
between the shell, Perl, Expect, etc etc, and the Telnet client and
server. Here's a short example:
define host xyzcorp.com
define user fred
undef password
set network type tcp/ip
set host \m(host)
if fail stop 1 Can't open connection to \m(host)
; Prompt locally for password -- it's not good to put passwords
; in scripts.
while not defined password {
askq password { Password for \m(user) at \m(host): } ; (doesn't echo)
}
input 20 login:
if fail stop 1 Timed out waiting for login: prompt
output \m(user)\13
input 10 Password:
if fail stop 1 Timed out waiting for Password: prompt
output \m(password)\13
connect
The \m(blah) notation indicates variable expansion, and \13 is the code
for carriage return.
The "connect" command at the end puts you online with the remote host so
you can interact with it directly. Instead of "connect" you can, of
course, also script any interactions with the host that you could do by
hand, plus many that you could not, like transferring files.
C-Kermit also can make dialup and other types of connections, so the same
scripting works for many connection types on many platforms.
Secure authentication methods (Kerberos, SRP) will be available in the
forthcoming 7.0 version.
- Frank